package com.bit.aop.proxy;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.aopalliance.intercept.Invocation;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKInvocation implements InvocationHandler {
    private Object target;//目标对象；（被代理对象）；
    public JDKInvocation(Object target){
        this.target=target;
    }
    //调用目标方法；
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我开始代理");
        Object invoke=method.invoke(target,args);//target为声明代理对像；
        System.out.println("我结束代理");
        return  invoke;

    }
}
